<template>
    <div class="mui-numbox" data-numbox-min="1">
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <!-- 监听他的改变值事件 -->
        <input class="mui-input-numbox" type="number" :value="initCount" @change="changeCount" ref="numberbox"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script >
    import mui from '../../lib/mui/js/mui.min.js'
    export default {
        data(){
        return {
            }
        },
        methods:{
            // 控件框的更改同步到本地存储中
            // 调用vuex公共数据。把id和修改的数值传过去
            changeCount(){
                this.$store.commit('updataCount',{
                    // id得父组件传过来
                    id:this.goodsid,
                    updataCount:this.$refs.numberbox.value
                })
            }
        },
        mounted(){
            // 必须加载Mui js文件来初始化数值
            mui('.mui-numbox').numbox()
        },
        // 接收父组件传过来的值
        props:["initCount","goodsid"]
    }

</script>

<style lang="scss" scpoed>
        .mui-numbox{
        width: 120px;
        height: 25px;
    }

</style>